6.1.4 Polygons (polygon)
1. Definition
An instance P of the data type polygon is a simple polygon
in the two-dimensional plane defined by the sequence of its vertices
in clockwise order. The number of vertices is called the size
of P. A polygon with empty vertex sequence is called empty.
2. Creation
a) P (listpoint pl)
b) P
introduces a variable of type polygon. is initialized to the
polygon with vertex sequence pl. The vertices in pl are given
in clockwise order and define a simple polygon. Variant b) creates the empty
polygon and assigns it to .
3. Operations
& truecm & truecm &
listpoint vertices
returns the vertex sequence of .
listsegment segments
returns the sequence of bounding segments
of in clockwise order.
listpoint intersection line l
returns P∩l as a list of points.
listpoint intersection segment s
returns P∩s as a list of points.
listpolygon intersection polygon Q
returns P∩Q as a list of points.
bool inside point p
returns true if p lies inside of P,
false otherwise.
bool outside point p
returns !.inside(p).
polygon translate vector v
returns P + v, i.e., the polygon created by
translating P by vector v. v
has dimension 2.
polygon translate double &alpha#alpha;, double d
returns the polygon created by a translation
of in direction α by distance d
polygon rotate point q, double &alpha#alpha;
returns the polygon created by a rotation of
P about point q by angle α.
double size
returns the size of .
bool empty
returns true if is empty, false otherwise.
4. Operators
&bool &polygon == polygon &test for equality
&bool &polygon != polygon &test for inequality